<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>添加成绩查看</title>
    <script src="../../script/mui.min.js"></script>
    <script src="../../script/jquery.min.js"></script>
    <script src="../../script/jquery.knob.js"></script>
    <link rel="stylesheet" href="../../css/mui.min.css" />
    <link rel="stylesheet" href="../../css/CFNetPP_Base.css">
    <link rel="stylesheet" href="../../css/base.css" />
    <link rel="stylesheet" href="../../css/testscore.css" />
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <style>
        body,html{
            width: 100%;
            /* overflow-x: hidden; */
        }
        th {
            font-size: 20px;
            text-align: center;
            height: 40px;
        }
        td {
            font-size: 18px;
            text-align: center;
            height: 40px;
            border: 1px solid #F2F2F2;
        }
        table {
            width: 100%;
        }
        .weih {
            width: 150px;
        }
        .imgs {
            margin-bottom: 3px;
            margin-right: 10px;
            width: 10px;
            height: 10px;
            vertical-align: middle;
        }
        .imgse {
            margin-bottom: 3px;
            margin-left: 10px;
            width: 15px;
            height: 15px;
            vertical-align: middle;
        }
        .setup{  
            padding: 5px;
            text-align: center;
        }
    </style>
</head>
<body style="overflow:-Scroll;overflow-y:hidden">
    <table id="grade" border="1" style="margin-top: 10px;">
       <!--  <tr>
            <td>学生</td>
            <td>总分</td>
            <td>教师／小组／学生评分</td>
        </tr>
        <tr>
            <td>李白</td>
            <td>90</td>
            <td>95/98/86</td>
        </tr>
        <tr>
            <td>杜甫</td>
            <td>78</td>
            <td>66/80/73</td>
        </tr> -->
    </table>
    <div class="noSign" hidden="hidden" id="noData">
        <img src="../../image/icon_img.png" width="60%">
        <p class="font16 top_15 base_dark_grey">
            暂无数据
        </p>
    </div>
    <div class="loadFailure" hidden="hidden" id="noNet">
        <img src="../../image/icon_img01.png" width="60%">
        <p class="">
            数据加载失败
        </p>
        <p>
            请检查您的网络
        </p>
        <button type="button" class="mui-btn mui-btn-outlined" onclick="loadNewData()">
			重新加载
		</button>
    </div>
</body>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/timeStampTool.js"></script>
<script src="../../script/processing_images.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/mui.min.js"></script>
<script type="text/javascript">
    var datase = []; //自评分数
    // 互评分数
    var dataseh = [];
    // 教师评分数
    var dataset = [];
    // 打分项
    var datasex = [];
    var datas = new Object();
    var ssd = [];
    var cfevals = "";
    var cs = [];
    var ssde = [];

    var dataList = new Array();
    var dataSource = [];
    var isFirst = 0;
    apiready = function() {

        dataSource = api.pageParam.data.data.scorelist;  //为了获得当前现场实操评分项中哪些是大项
        loaddate();
        api.addEventListener({
            name: 'mylist_up'
        }, function(ret, err) {
            loaddate();
        });
        api.addEventListener({
            name: 'scrollTop'
        }, function(ret, err) {
            $('html,body').animate({scrollTop: '0px'}, 100);
        });
    };
    function loaddate() {
        var params = {
            uid : $api.getStorage('cfnetppuid'),
            jid : $api.getStorage('cfnetppjxid'),
            pid: api.pageParam.pid,
            vid: api.pageParam.vid
        };
        if (isFirst == 0) {
            showProgress();
            isFirst = 1;
        }
        // var url = "http://base.cfnet.org.cn/course/Sitenow_Normal/getTeacherScore";
        // console.log(JSON.stringify(params)+'\n'+url_getTeacherScore);
        cfnetppPOST(url_getTeacherScore, params, true, function(data, status) {
            api.hideProgress();
            // alert(JSON.stringify(params));
            if (status == 'success') {
                // alert(JSON.stringify(data));
                inits(data);
                $('#noData').hide();
            } else {
                $('#noData').show();
            }
        });
    }
    // 获取打分项信息
    function inits(gradedata) {
        dataList = gradedata.data;
        ListView();
    }
    function ListView() {
        x = document.getElementById("grade"); //获取到Table标签
        x.innerHTML = "";
        var dar = '<tbody>' + '<tr>' + '<td style="width:80px;font-size:16px;">' + '学生' + '</td>' + '<td style="width:80px;font-size:16px;">' + '总分' + '</td>' + '<td class="weih" style="font-size:14px;">' + '教师/小组/学生评分' + '</td>' + '</tr>';
        for (var m = 0; m < dataList.length; m++) {
            var item = dataList[m];
            var stuName = item.rename;
            // alert("次数"+m);
            // alert(item.score.length);
            var teaScoreCalculate = 0;
            if (item.teascore[0] == "未评分") {
            }else{
                //求该现场实操所有项的总分,按主项和算的
                for (var i = 0; i < dataSource.length; i++) {
                    if (dataSource[i].fallscore == "0" || dataSource[i].fallscore == 0) {
                        teaScoreCalculate += parseInt(item.score[i]);
                    }
                }
                // alert("总"+teaScoreCalculate);
                // alert(JSON.stringify(item.teascore));
                for (var j = 0; j < item.score.length; j++) {
                    for (var i = 0; i < item.teascore.length; i++) {
                        if (i == j) {
                            teaScoreCalculate = teaScoreCalculate - (parseInt(item.score[j]) - parseInt(item.teascore[i]));
                        }
                    }
                }
                if (parseInt(teaScoreCalculate) <= 0) {
                    teaScoreCalculate = 0;
                }
            }
            var StuScoreCalculate = 0;
            if (item.peerscore[0] == "未评分") {
            }else{
                //求该现场实操所有项的总分,按主项和算的
                for (var i = 0; i < dataSource.length; i++) {
                    if (dataSource[i].fallscore == "0" || dataSource[i].fallscore == 0) {
                        StuScoreCalculate += parseInt(item.score[i]);
                    }
                }
                for (var j = 0; j < item.score.length; j++) {
                    for (var i = 0; i < item.peerscore.length; i++) {
                        if (i == j) {
                            StuScoreCalculate = StuScoreCalculate - (parseInt(item.score[j]) - parseInt(item.peerscore[i]));
 
                        }
                    }
                }
            }
            if (parseInt(StuScoreCalculate) <= 0) {
                StuScoreCalculate = 0;
            }
            var selfScoreCalculate = 0;
            if (item.myselfscore[0] == "未评分") {
            }else{
                //求该现场实操所有项的总分,按主项和算的
                for (var i = 0; i < dataSource.length; i++) {
                    if (dataSource[i].fallscore == "0" || dataSource[i].fallscore == 0) {
                        selfScoreCalculate += parseInt(item.score[i]);
                    }
                }
                for (var j = 0; j < item.score.length; j++) {
                    for (var i = 0; i < item.myselfscore.length; i++) {
                        if (i == j) {
                            selfScoreCalculate = selfScoreCalculate - (parseInt(item.score[j]) - parseInt(item.myselfscore[i]));
                        }
                    }
                }
            }
            if (parseInt(selfScoreCalculate) <= 0) {
                selfScoreCalculate = 0;
            }
            var totalScore = 0;
            var tea = "--";
            var stu = "--";
            var my = "--";
            //小组
            if (item.peerscore[0] == "未评分") {
                StuScoreCalculate = 0;
            }else{
               stu = StuScoreCalculate;
            }
            //自己
            if (item.myselfscore[0] == "未评分") {
                selfScoreCalculate = 0;
            }else{
               my = selfScoreCalculate;
            }
            //教师
            if (item.teascore[0] == "未评分") {
                teaScoreCalculate = 0;
            }else{
               tea = teaScoreCalculate;
               // alert("教师端显示的分数"+tea);
            }
            totalScore = parseInt(teaScoreCalculate) * item.teacher / 100 + parseInt(StuScoreCalculate) * item.student / 100 + parseInt(selfScoreCalculate) * item.oneself / 100;
            var value = Number(totalScore);
            value = value.toFixed(2); 
            value=parseFloat(value);
            if(!isNaN(value)){
               // alert("是数字");
            }else{
               // alert("不是数字");
               value = 0;
            }
            // alert("value"+value);
            dar += '<tr>'+
                '<td style="font-size:14px;">'+stuName+'</td>'+
                '<td style="font-size:14px;">'+value+'</td>'+
                '<td style="font-size:14px;">'+tea+' / '+stu+' / '+my+'</td>'+
            '</tr>';
        }
        x.innerHTML = dar + '</tbody>';
    }
    function loadNewData() {
        $('#noNet').hide();
        $('#noData').hide();
        api.sendEvent({
            name: 'loadnew'
        });
        api.closeFrameGroup({
            name: 'groups'
        });
    }
</script>

</html>
